package com.chao.product.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.chao.mapper.PmsProductMapper;
import com.chao.model.PmsProduct;
import com.chao.model.PmsProductExample;
import com.chao.product.exception.handler.SystemBlockHandlerException;
import com.chao.product.service.ProductService;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ProductServiceImpl implements ProductService {

    @Autowired
    PmsProductMapper pmsProductMapper;

    @SentinelResource(value = "getAllProductService",
            blockHandler = "testHelloBlockHandlerService",
            blockHandlerClass = SystemBlockHandlerException.class)
    @Override
    public List<PmsProduct> getAllProduct(){
        PmsProductExample pmsProductExample = new PmsProductExample();
        pmsProductMapper.selectByExample(pmsProductExample);
        return pmsProductMapper.selectByExample(pmsProductExample);
    }
}
